home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / cenviw1.zip / BOOTED1.CMM < prev    next >
Text File  |  1993-07-12  |  2KB  |  57 lines

  1. /************************************************************
  2.  *** BootEd1 - Sample Cmm code to demonstrate uses of the ***
  3.  ***           WinExec() function.                        ***
  4.  ************************************************************/
  5.  
  6. #include <WinExec.lib>
  7. #include <MsgBox.lib>
  8. #include <WinUtil.lib>
  9.  
  10. MessageBox("This example CEnvi program will start\n"
  11.            "NotePad to edit both C:\\Config.sys and\n"
  12.            "C:\\Autoexec.bat, and then display them\n"
  13.            "both on the screen together.  This example\n"
  14.            "is like BootEd2 but this uses WinExec().",
  15.            "BootEd1 - Description");
  16.  
  17. // start up two versions of notepad with the two files we care about
  18. MustWinExec("NotePad.exe c:\\Config.sys");
  19. MustWinExec("NotePad.exe c:\\AutoExec.bat");
  20.  
  21. // Give the two processes 3/4 second to start up
  22. Suspend(750);
  23.  
  24. // Get the WindowHandles for both programs by searching for their name
  25. Config = MustGetWindowHandle("NOTEPAD - CONFIG.SYS");
  26. AutoExec = MustGetWindowHandle("NOTEPAD - AUTOEXEC.BAT");
  27.  
  28. // position these two windows to fill the top-half and the bottom-half of
  29. // the screen
  30. ScreenWidth = GetSystemMetrics(SM_CXSCREEN);
  31. ScreenHeight = GetSystemMetrics(SM_CYSCREEN);
  32.  
  33. MoveWindow(Config,0,0,ScreenWidth,ScreenHeight/2,True);
  34. MoveWindow(AutoExec,0,ScreenHeight/2,ScreenWidth,ScreenHeight/2,True);
  35.  
  36.  
  37. MustWinExec(command)
  38. {
  39.    result = WinExec(command);
  40.    if ( result < 32 ) {
  41.       sprintf(ErrorMessage,"That call to WinExec returned error: %d",ErrorNumber);
  42.       MessageBox(ErrorMessage);
  43.       exit(1);
  44.    }
  45. }
  46.  
  47. MustGetWindowHandle(title)
  48. {
  49.    handle = GetWindowHandle(title);
  50.    if ( 0 == handle ) {
  51.       sprintf(ErrorMessage,"%s did not load.",title);
  52.       MessageBox(ErrorMessage);
  53.       exit(1);
  54.    }
  55.    return(handle);
  56. }
  57.